<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache">
    <title>模型管理</title>
    <!--<link rel="stylesheet" href="lib/Jquery-EasyUi/css/easyui.css">-->
    <!--<script src="lib/jquery/dist/jquery.js"></script>-->
    <!--<script src="js/jquery.cookie.js"></script>-->
    <!--<script src="js/ajax-util.js"></script>-->
    <!--<script src="lib/art-template/lib/template-web.js"></script>-->
    <!--<script src="lib/Jquery-EasyUi/js/jquery.easyui.min.js"></script>-->

    <link rel="stylesheet" href="/lib/jquery-easyui/themes/default/easyui.css">
    <script src="/lib/jquery/dist/jquery.js"></script>
    <script src="/common/jquery.cookie.js"></script>
    <script src="/common/ajax-util.js"></script>
    <script src="/lib/art-template/lib/template-web.js"></script>
    <script src="/lib/jquery-easyui/jquery.easyui.min.js"></script>


</head>
<body>
<div id="top">
</div>
<h2>模型列表</h2>
<hr>
<form action="/models/newModel" method="post">
    <table>
        <tr>
            <td>name:<input type="text" id="name" name="name" value="new-process"/></td>
            <td>key:<input type="text" id="key" name="key" value="process"/></td>
            <td><a href="javascript: AJAX.POST('/models/newModel')">绘制流程</a></td>
        </tr>
    </table>
</form>
<!--<a href="javascript: AJAX.POST('/models/newModel')">绘制流程</a>-->
<table border="1" id="model-list">
    <tr>
        <td>模型编号</td>
        <td>模型名称</td>
        <td>版本</td>
        <td>创建时间</td>
        <td>操作</td>
    </tr>
    <script id="models" type="text/html">
        <tr>
            <td>模型编号</td>
            <td>模型名称</td>
            <td>版本</td>
            <td>创建时间</td>
            <td>操作</td>
        </tr>
        {{each rows.list}}
        <tr>
            <td>{{$value.id}}</td>
            <td>{{$value.name}}</td>
            <td>{{$value.version}}</td>
            <td>{{$value.createTime}}</td>
            <td>
                <a href="/modeler.html?modelId={{$value.id}}">编辑</a>
                <a href="javascript: AJAX.DELETE('/models/{{$value.id}}')">删除</a>
                <a href="javascript: AJAX.POST('/models/{{$value.id}}/deployment')">发布</a>
            </td>
        </tr>
        {{/each}}
    </script>
</table>
<hr>
<h2>部署列表</h2>
<hr>
<table border="1" id="deployment-list">
    <tr>
        <td>编号</td>
        <td>名称</td>
        <td>部署时间</td>
        <td>操作</td>
    </tr>
    <script id="deployments" type="text/html">
        <tr>
            <td>编号</td>
            <td>名称</td>
            <td>部署时间</td>
            <td>操作</td>
            <td>状态</td>
        </tr>
        {{each rows.list}}
        <tr>
            <td>{{$value.id}}</td>
            <td>{{$value.name}}</td>
            <td>{{$value.deploymentTime}}</td>
            <td>
                <a href="javascript: AJAX.DELETE('/deployments/{{$value.id}}')">删除</a>
                <a href="javascript: $.post('/startProcess/{{$value.id}}')">启动</a>
                <a href="javascript: $.post('/pauseByDeploymentKey/{{$value.name}}')">Pause</a>
                <a href="javascript: $.post('/workStartByDeploymentKey/{{$value.name}}')">开工</a>
                <a href="javascript: $.post('/workCompleteByDeploymentKey/{{$value.name}}')">完工</a>
            </td>
            <td>
                <a href="javascript: openImg('{{$value.id}}')">当前状态</a>
            </td>
        </tr>
        {{/each}}
    </script>
</table>
<script>
    $(function () {
        AJAX.GET("/models", null
            , function (result) {
                var html = template("models", result);
                $("#model-list").html(html);
            });
        AJAX.GET("/deployments", null
            , function (result) {
                var html = template("deployments", result);
                $("#deployment-list").html(html);
            });
    })

    function openImg(deploymentId) {
        if ($('#win').length > 0) {
            $(".win").load(location.href + " .refresh");
        }
        $("#win").html("<img src='http://localhost:8081/processView/viewByDeploymentId/" + deploymentId + "' />");
    }
</script>
<div id="win"></div>
</body>
</html>
